#include "testIntrinsicImage.h"
#include "cvxImage.h"
#include <iostream>
#include <time.h>
#include <vector>
#include <algorithm>
#include <list>
#include "nvmath.h"
#include "least_square.h"
#include "cvxQuadTree.h"
#include "cvxSf.h"
#include "cvxStroke.h"
#include "cvxIntrinsicSolver.h"
#include "cvxIo.h"
#include "cvxEMTreeSolver.h"
#include "cvxStereoIntrinsicSolver.h"

using namespace std;
using namespace cv;

#if 0
int main(int argc, char **argv)
{
	char *leftFileName = NULL;
	char *rightFileName = NULL;
	int stddevThreshold = 5;
	bool useMatch = false;

	if(argc != 4)
	{
		printf("usage: StereoIntrinsicImage leftImageName rightImageName isMatch\n");
		return 1;
	}

	leftFileName = argv[1];
	rightFileName = argv[2];
	useMatch = ((argv[3][0] - '0') == 1);

//	char *leftFileName = "org_image\\pine_apple\\pL_700.jpg";
//	char *rightFileName = "org_image\\pine_apple\\pR_700.jpg";


	float threshold = 0.999;
	int sizeThreshold = 256;

	Mat leftImage = imread(leftFileName, 1);	
	Mat rightImage = imread(rightFileName, 1);

	assert(!leftImage.empty());
	assert(!rightImage.empty());

	//set E tree
	CvxStereoIntrinsicSolver solver;
	solver.setImage(leftImage, rightImage, threshold);
	solver.SetETree(stddevThreshold, sizeThreshold);
	solver.MatchLeftRightETree(2.0, 4, false);
	solver.SolveETree(true, useMatch, false);

	solver.CalcMTree(true);
	solver.SolveMtree(true, false);
	solver.UpsampleAvector(true);


	cv::waitKey(0);

	return 1;
}
#endif